package com.example.eliminateifelse.designmode;

import com.example.eliminateifelse.entity.Item;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

/**
 * @version 1.0.0
 * @className: NormalUserCart
 * @description:
 * @author: zhangjunfa
 * @date: 2023/1/5 14:11
 */
@Service(value = "NormalUserCart")
public class NormalUserCart extends AbstractCart {
    @Override
    protected void processCouponPrice(long userId, Item item) {
        item.setCouponPrice(BigDecimal.ZERO);
    }

    @Override
    protected void processDeliveryPrice(long userId, Item item) {
        item.setDeliveryPrice(item.getPrice()
                .multiply(BigDecimal.valueOf(item.getQuantity()))
                .multiply(new BigDecimal("0.1")));
    }
}
